#include<bits/stdc++.h>
using ll=long long ;
using namespace std;

const int N=5e5+10;
int a[N] ;
int t[N];
ll ret=0;

void merge(int l,int r) {
	if(r-l+1<=1)return ;
	int m=(l+r)>>1;
	merge(l,m);merge(m+1,r);
	
	int c1=l,c2=m+1,c=l;
	while(c1<=m&&c2<=r) {
		if(a[c1]>a[c2])t[c++]=a[c1++],ret+=r-c2+1;
		else t[c++]=a[c2++]; 
	}
	while(c1<=m)t[c++]=a[c1++];
	while(c2<=r)t[c++]=a[c2++];
	
	for(int i=l;i<=r;i++)a[i]=t[i]; 
}

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	
	merge(1,n);
	cout<<ret<<endl;
	return 0;
}
